package com.paireach.szwolaiyun.newFragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.paireach.szwolaiyun.R;

public class HomeTopFragment extends Fragment {

    public static final String TAG = "HomeTopFragment";
    private View rootView;
    private TextView main_userphone, main_username;
    //====================data
    private String name, phone;

    public static HomeTopFragment getInstance(String name, String phone) {
        HomeTopFragment homeFragment = new HomeTopFragment();
        Bundle bundle = new Bundle();
        bundle.putString("name", name);
        bundle.putString("phone", phone);
        homeFragment.setArguments(bundle);
        return homeFragment;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initView();
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle bundle = getArguments();
        if (bundle != null) {
            name = bundle.getString("name");
            phone = bundle.getString("phone");
        }
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        rootView = inflater.inflate(R.layout.fragment_home_top_v2, container, false);
        return rootView;
    }

    private void initView() {
        main_userphone = (TextView) rootView.findViewById(R.id.main_userphone);
        main_username = (TextView) rootView.findViewById(R.id.main_username);
        main_username.setText(name);
        main_userphone.setText(phone);
    }
}
